﻿
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>管理登录</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="~/Content/css/font.css">
    <link rel="stylesheet" href="~/Content/css/login.css">
    <link rel="stylesheet" href="~/Content/css/index.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="~/Content/lib/layui/layui.js" charset="utf-8"></script>

</head>
<body class="login-bg">
    <canvas id="fullstarbg">你的浏览器不支持canvas标签</canvas>
    <div class="login">
        <div class="message">企业管理系统登录</div>
        <div id="darkbannerwrap"></div>
        <form method="post" id="adminform" class="layui-form">

            <input name="username" placeholder="用户名" id="username" type="text" lay-verify="required" class="layui-input">
            <hr class="hr15">

            <input name="password" lay-verify="required" id="password" placeholder="密码" type="password" class="layui-input">
            <hr class="hr15">

            <input name="code" lay-verify="required" id="code" style="width:140px;" placeholder="验证码" type="text">
            <img id="imgRandCode" src="/Back/Home/GetRandCode" /><button class="layui-btn" onclick="reRandCode()">看不清</button>
            <hr class="hr15">

            <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
            <hr class="hr20">
        </form>
    </div>
    <script>
        function reRandCode() {
            var id = Math.ceil(Math.random() * 1000);
            $("#imgRandCode").attr("src", "/Back/Home/GetRandCode/" + id);

        }

        layui.use(['form'],
            function () {
                $ = layui.jquery;
                var form = layui.form,
                    layer = layui.layer;

                //监听提交
                form.on('submit(login)',
                    function (data) {
                        $.ajax({
                            url: "/Back/Home/LoginDeal",
                            type: "post",
                            data: {
                                username: $("#username").val(),
                                password: $("#password").val(),
                                code: $("#code").val()
                            },
                            dataType: "json",
                            success(res) {
                                if (res.code == 0) {
                                    window.location.href = "/Back/Home/Index"
                                } else {
                                    layer.msg(res.msg);
                                }
                            }
                        })
                        return false;
                    }
                );
            });

    </script>

    <!-- 底部结束 -->
</body>
</html>
